#encoding:UTF-8
import re
import mylib
import pythonlibSB


def get_hot_link():
    try:
        results = []
        
        content = mylib.get_content('http://kenh14.vn')
        hot_10_link = []
        hot_10_content = pythonlibSB.s_string(content,'class="focus-center-top"','div')
#        print hot_10_content
        reg = re.compile('(<a)(.*?)(title=)(.*?)(href=")(.*?)(")')
        if reg.search(hot_10_content):
            url10 = reg.search(hot_10_content).group(6)
            url10 = url10 if url10.find('http://')!=-1 else ('http://kenh14.vn'+url10)
            hot_10_link.append(url10)
            
        results.append(hot_10_link)
        
        hot_9_link = []
        hot_9_content = pythonlibSB.s_string(content,'class="focus-center-bottom clearfix"','div')
        for i in re.finditer('(<a)(.*?)(class=")(.*?)(href=")(.*?)(")',hot_9_content):
            url9 = i.group(6) if i.group(6).find('http://')!=-1 else ('http://kenh14.vn'+i.group(6))
            hot_9_link.append(url9)
        results.append(hot_9_link)
        
        hot_8_link = []
        hot_8_content = pythonlibSB.s_string(content,'class="focus-left-hot"','div')
        for j in re.finditer('(<a)(.*?)(title=)(.*?)(href=")(.*?)(")',hot_8_content):
            url8 = j.group(6) if j.group(6).find('http://')!=-1 else ('http://kenh14.vn'+j.group(6))
            hot_8_link.append(url8)
        results.append(hot_8_link)
        
        
        hot_7_link = []
        
        results.append(hot_7_link)
        
        return results
    
    except:
        return []
    
    
if __name__ == "__main__":
    myres = get_hot_link()
    print myres